<template >
  <div class="container">
    <van-nav-bar
      title="我的安排"
      left-text="返回"
      style="background-image: linear-gradient(135deg, #4CF6FC 7%, #3C7FB2 59%)"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="info">
      <van-card v-for="item in PracticeList" :key="item.id"
        :desc="item.create_time"
        :title="item.catogary"
        :thumb="require('../../assets/from.png')"
      >
        <template #footer>
          <van-button type="primary" @click="DetailHandel(item.id)" size="normal">查看详情</van-button>
        </template>
      </van-card>
    </div>
    <div class="pagination">
      <van-pagination v-model="pageNum" @change="pageChange" :total-items="pageTotal" :show-page-size="pageSize" force-ellipses
      />
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
import chauffeur from "../js/chauffeur";
export default {
  data() {
    return{
    pageSize:4,
    pageNum:1,
    pageTotal:1,
    PracticeList:[],
    }
  },
  mounted(){
   this.getAllPractice(1)
  },
  methods:{
    // 换页
    pageChange(value){
      this.getAllPractice(value)
    },
    // 左边按钮
    onClickLeft(){
      this.$router.go(-1)
    },
    getNowFormatDateTime3:(date)=>{//获取后一天日期
        let time = ''
        if(date){
            time=new Date(date).getTime()+24*60*60*1000;
        }else{
            time=new Date().getTime()+24*60*60*1000;
        }
        let afterday=new Date(time);
        return afterday=afterday.getFullYear() + "-" + (afterday.getMonth()> 9 ? (afterday.getMonth() + 1) :  + (afterday.getMonth() + 1)) + "-" +(afterday.getDate()> 9 ? (afterday.getDate()) : "0" + (afterday.getDate()));
    },
    // 教练员获取自己的全部练车安排记录
    getAllPractice(value){
      let requestBody = {
        pageSize:this.pageSize,
        pageNum:value,
      }
      chauffeur.getAllPractice(requestBody).then(res => {
        if(res.data.code === 0){
          this.PracticeList = res.data.data.list
          this.pageNum = value
          this.pageTotal = res.data.data.Total
        }
      })
    },
    // 查看练车表详情
    DetailHandel(id){
      this.$router.push({path:'/manager/Record',query:{id:id}})
    },
  }
}
</script>

<style scoped lang="less">
.container{
  .info{
    margin-top: 8%;
    .van-card{
      margin-bottom: 5%;
    }
  }
  .pagination{
    margin-top: 8%;
  }
}


 /deep/ .van-nav-bar__title {
    color: #fff;
  }

  /deep/ .van-nav-bar__text {
    color: #fff;
  }

  /deep/ .van-icon-arrow-left {
    color: #fff;
  }
</style>